package com.example.czxyuser.web;

import com.example.czxyuser.mapper.UserMapper;
import com.yc.czxy.bean.Result;
import com.yc.czxy.bean.user;
import com.yc.czxy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: chengzixy1
 * @description:
 * @author:
 * @create: 2021-08-30 15:56
 */


@RestController
@RequestMapping("/user")
public class UserAction {

    @Autowired
    private UserMapper userMapper;

    /**
     * 登录
     * @param userName 用戶名稱
     * @param passWord 密碼
     * @return
     */
    @GetMapping("/login")
    public user login(@RequestParam("userName") String userName,@RequestParam("passWord")String passWord){
        user user = new user();
        user u =userMapper.selectForLogin(user.setUsername(userName).setPassword(passWord));
        return u;
    }

    /**
     * 注册
     */
    @RequestMapping("/registeruser")
    public Result<user> registeruser(user user){
        int i =userMapper.insertuser(user);
        return new Result<>(1,"注册成功",null);
    }

    @GetMapping("test")
    public R test(){
        return R.ok("请求成功");
    }

}
